package seminar.evaluate;

import seminar.LectureEvent;
import seminar.Room;
import seminar.Semester;

/**
 * Evaluate how often the room changes
 * @author Johannes Degler
 *
 */
public class RoomChangeEvaluator implements IEvaluator{

	@Override
	public int getPoints(final Semester semester) {
		int points = 0;

		//Room changes
		Room lastRoom;
		for(int day = 0; day < 5; day++){
			lastRoom = null;
			for(int slot = 0; slot < 6; slot++){
				final LectureEvent lectureEvent = semester.getEvents()[day][slot];
				if(lectureEvent == null)
					continue;
				final Room room = lectureEvent.getRoom();
				if(lastRoom == null)
					lastRoom = room;
				else if(lastRoom.equals(room))
					points += 2;
				else{
					lastRoom = room;
					points -= 1;
				}
			}
		}
		return points;
	}

}
